<?php
/**
 * Default Theme Custimization Template
 *
 * @package OWL
 * @subpackage Default Template
 * @author KeiMOon
 * @since 1.0
 */

class Template_Theme_Customize extends Owl_Master_Template {
    protected function init() {
        $user = Owl_User::get_instance();
        if (!$user->is_logged_in()) {
            Owl_Functions::go_to_template("login");
        }
        if ($_GET["var"] != Owl_Theme_Control::get_current_theme()) {
            Owl_Functions::go_to_template("theme-manager");
        }
        if (Owl_Theme_Control::is_customizable(Owl_Theme_Control::get_current_theme()) != 1) {
            Owl_Functions::go_to_template("theme-manager");
        }
        update_option("current_body_class", "custom");
        assign("title", get_option("site_name") . " - " . __("Theme customization"));
        assign("page-title", __("Theme customization"));
        enqueue_style('default-setting,default-icon,default-colorpicker,default-theme-customize,default-ajax');
        enqueue_script('default-theme-customize');

        $this->customization = Owl_Theme_Control::get_customization(Owl_Theme_Control::get_current_theme());
        
    }

    protected function main_content() {
?>
<div id="setting-navigation">
    <?php Owl_Default_Content::setting_navigation(); ?>
    <div style="clear:both;"></div>
</div>
<div id="setting-page-header" class="has-icon icon-theme-customize-48">
    <div id="setting-page-title">
        <?php put("page-title"); ?>
    </div>
</div>
<div id="setting-main-content">
    <form action="<?php Owl_Link::ajax_url() ?>theme-ajax.php" method="POST" id="form_customize_theme"  >
    <div class="setting-content inset">        
        <input type="hidden" name="action" value="customize_theme" />
        <table border="0" cellpadding="0" cellspacing="0">
            <tbody>
                <?php foreach($this->customization as $customization) { ?>
                <tr>
                    <th width="50%">
                        <?php echo $customization["customize_name"]; ?>
                    </th>
                    <td>
                        <div class="color-selector"><div style="background-color:<?php echo $customization["value"]; ?>;"></div></div>
                        <input type="hidden" name="<?php echo Owl_Theme_Control::encode_customize_name($customization); ?>" value="<?php echo $customization["value"]; ?>" />
                    </td>
                </tr>
                <?php } ?>
                <tr>
                    <td class="form-button-pane" colspan="2">
                        <input type="submit" name="submit" value="Submit" class="ajax-submit form-button" title="form_customize_theme" />
                        <input type="submit" name="cancel" value="Cancel" class="cancel form-button"/>
                        <input type="submit" name="default" value="Default" class="default form-button"/>
                    </td>
                </tr>
            </tbody>
        </table>
        <?php Owl_Default_Content::print_ajax_feedback(); ?>
    </div>
    </form>
</div>
<?php
    }
}